import request from '@/config/axios'

// 合同管理 VO
export interface ContractVO {
  id: number // 编号
  name: string // 合同名称
  typeId: number // 分类ID
  userIds: string //用户
  fileUrls: string // 合同文件
  expiredTime: Date // 合同到期时间
  notifyDays: number // 提前提醒天数
  remark: string // 备注
  sort: number // 排序
  status: number // 状态
  description: string //处理说明
}

// 合同管理 API
export const ContractApi = {
  // 查询合同管理分页
  getContractPage: async (params: any) => {
    return await request.get({ url: `/school/contract/page`, params })
  },

  // 查询合同管理详情
  getContract: async (id: number) => {
    return await request.get({ url: `/school/contract/get?id=` + id })
  },

  // 查询合同处理记录列表
  getContractRecordPage: async (contractId: number) => {
    return await request.get({ url: `/school/contract-record/list?contractId=${contractId}` })
  },

  // 新增合同管理
  createContract: async (data: ContractVO) => {
    return await request.post({ url: `/school/contract/create`, data })
  },

  // 修改合同管理
  updateContract: async (data: ContractVO) => {
    return await request.put({ url: `/school/contract/update`, data })
  },

  // 删除合同管理
  deleteContract: async (id: number) => {
    return await request.delete({ url: `/school/contract/delete?id=` + id })
  },

  // 归档合同
  storeContract: async (params) => {
    return await request.post({ url: `/school/contract/store`, params })
  },

  // 导出合同管理 Excel
  exportContract: async (params) => {
    return await request.download({ url: `/school/contract/export-excel`, params })
  },
  // 根据月份查询合同信息
  getContractByMonth: async (month) => {
    return await request.get({ url: `/school/contract/get-by-month?month=${month}` })
  },
  // 查询某天到期及提醒的合同列表
  getContractByDay: async (day) => {
    return await request.get({ url: `/school/contract/get-by-day?day=${day}` })
  }
}
